/*
 * @# Avatars.java 2011-12-30 下午06:18:24
 * 
 * Copyright (C) 2010 - 2011 广州羿安信息科技有限公司
 * Guangzhou ianswer information technology co. ltd.
 * 
 * All rights reserved!
 */
package com.ianswer.px.user;

import org.apache.commons.io.FilenameUtils;
import org.apache.commons.lang.StringUtils;

/**
 * 对用户的avatar进行处理.
 * 
 * @author alvin hwang
 */
public final class Avatars {

	/**
	 * 获取大小40x40大小的头像路径.
	 * 
	 * @param avatar
	 *            用户上传的原始头像地址.
	 * @return 大小40x40大小的头像路径.
	 */
	public static String getS40Path(String avatar) {
		return path(avatar, "-s40");
	}
	
	private static String path(String avatar, String name) {
		if (StringUtils.isEmpty(avatar)) {
			return StringUtils.EMPTY;
		}
		return FilenameUtils.getFullPath(avatar) + FilenameUtils.getBaseName(avatar) + name + "."
				+ FilenameUtils.getExtension(avatar);
	}
}
